import 'package:flutter/cupertino.dart';

import '../../../lib_baseview/widget/dialogs.dart';
import '../../../lib_runtime/logger.dart';
import '../../../resource/language/generated/l10n.dart';
import '../../m_chatroom.dart';
import '../config/room_config.dart';

class RoomCreatePageModel extends ChangeNotifier {
  // late Channel channel;
  // ChannelLabel channelLabel = ChannelLabel.MAKE_FRIENDS_LABEL;

  // Row(
  //   mainAxisAlignment: MainAxisAlignment.spaceAround,
  //   children: [
  //     Image.asset(
  //       "assets/images/ic_room_tool_chat.png",
  //       width: 75,
  //       height: 85,
  //       fit: BoxFit.fill,
  //     ),
  //     Image.asset(
  //       "assets/images/ic_room_game.png",
  //       width: 75,
  //       height: 85,
  //       fit: BoxFit.fill,
  //     ),
  //     Image.asset(
  //       "assets/images/ic_room_ktv.png",
  //       width: 75,
  //       height: 85,
  //       fit: BoxFit.fill,
  //     ),
  //     Image.asset(
  //       "assets/images/ic_room_wolf.png",
  //       width: 75,
  //       height: 85,
  //       fit: BoxFit.fill,
  //     )
  //   ],
  // ),

  RoomCreatePageModel() {
    // channel = Channel.create();
  }

  changePrivacy(bool isPrivacy) {
    // channel.isPrivacy = isPrivacy;
    notifyListeners();
  }

  // clickChannelLabel(ChannelLabel channelLabel) {
  //   this.channelLabel = channelLabel;
  //   notifyListeners();
  // }

  onConfirm(BuildContext context) async {
    // RLog.d("create room channel:${channel.toProto3Json()}");
    showLoadingDialog();

    // var result = await RtcApi.instance.createChannel(
    //   CreateChannelReq(
    //     title: channel.title,
    //     theme: channel.theme,
    //     isPrivacy: channel.isPrivacy,
    //     label: channelLabel,
    //   ),
    // );

    // if (!result.isSuccess) {
    //   showToast(T.current!.create_room_faile(result.errorMsg ?? ''));
    //   dismissLoadingDialog();
    //   return;
    // }

    /// 房间创建成功后，若未使用默认名称及主题，增加一个提示：房间信息正在审核中，审核通过前展示默认名称及主题
    // if (channel.title.isNotEmpty || channel.theme.isNotEmpty) {
    //   showToast(T.current!.room_reviewing_tips);
    // }

    Navigator.of(context).pop();
    dismissLoadingDialog();

    /// 创建房间成功之后，自动进入该房间
    RoomPage.show(
      context,
      "1000351",
      // result.data!.channel.channelId.toInt(),
    );
  }
}
